#pragma comment(linker, "/STACK:10000000")
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
#include <string>
#include <cstring>
#define ldb long double
#define LL long long
#define fi first
#define se second
#define fill(a, c) memset(a, c, sizeof(a))
#define sqr(a) ((a) * (a))
#define nextLine() {int c = 0; while((c = getchar()) != 10 && c != EOF);}
#define getBit(mask, k) (((mask) / pw[k]) % pw[1])
#define setBit(mask, k, l) (((mask) / pw[k + 1] * pw[1] + (l)) * pw[k] + ((mask) % pw[k]))
#define debug(a) cerr << #a << " = " << a << " ";
#define debugl(a) cerr << #a << " = " << a << "\n";
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define ff first
#define ss second 
const ldb LDINF = 9128739847123.00;
const ldb eps = 1e-9;
const int inf = 1 << 28;
const ldb pi = fabsl(atan2l(0.0, -1.0));
using namespace std;



string t = "lucky";
int cnt[1232][5];
string result, temp, tt, s;
int n;
int change[1232];

void load()
{
//    scanf("%s", s);
	cin >> s;
	n = s.size();
}

void solve()
{
	if (n < 9)
	{
		printf("unlucky\n");
		return;
	}
	result = "";
	int res_cnt = inf;
	
	for (int k = 0; k < 2; k++)
	{
		if (k == 0) t = "lucky";
		else t = "ykcul";
	temp = s;
	for (int i = 0; i < n - i - 1; i++)
	{
		for (int j = 0; j < 5; j++)
			cnt[i][j] = (s[i] != t[j])*1 + (s[n - i - 1] != t[j])*1;
		change[i] = (i ? change[i - 1] : 0) * 1 + (s[i] != s[n - i - 1])*1;
		temp[i] = temp[n - i - 1] = min(s[i], s[n - i - 1]);
	}
	
	if (n % 2 == 1)
	{
		change[n / 2] = (n / 2 ? change[n / 2 - 1] : 0);
		for (int j = 0; j < 5; j++)
			cnt[n / 2][j] = (s[n / 2] != t[j]);
	}
	for (int i = 0; i + 4 <= n - (i + 4) - 1; i++)
	{
		if (change[(n - 1) >> 1] - change[i + 4] 
		+ (i ? change[i - 1] : 0) 
		+ cnt[i][0] + cnt[i + 1][1] + cnt[i + 2][2] + cnt[i + 3][3] + cnt[i + 4][4] < res_cnt)
		{
			res_cnt = change[(n - 1) >> 1] - change[i + 4] 
			+ (i ? change[i - 1] : 0) 
			+ cnt[i][0] + cnt[i + 1][1] + cnt[i + 2][2] + cnt[i + 3][3] + cnt[i + 4][4];
			result = temp;
			result[i] = result[n - i - 1] = t[0];
			result[i + 1] = result[n - i - 2] = t[1];
			result[i + 2] = result[n - i - 3] = t[2];
			result[i + 3] = result[n - i - 4] = t[3];
			result[i + 4] = result[n - i - 5] = t[4];
		}
		else if (change[(n - 1) >> 1] - change[i + 4] 
		+ (i ? change[i - 1] : 0)
		+ cnt[i][0] + cnt[i + 1][1] + cnt[i + 2][2] + cnt[i + 3][3] + cnt[i + 4][4] == res_cnt)
		{
			tt = temp;
			tt[i] = tt[n - i - 1] = t[0];
			tt[i + 1] = tt[n - i - 2] = t[1];
			tt[i + 2] = tt[n - i - 3] = t[2];
			tt[i + 3] = tt[n - i - 4] = t[3];
			tt[i + 4] = tt[n - i - 5] = t[4];
			result = min(tt, result);
		}
	}
	}
	printf("%s %d\n", result.c_str(), res_cnt);
}

#define file "lucky_palin"
int main()
{
	#ifndef ONLINE_JUDGE
		freopen(file".in", "rt", stdin);
		freopen(file".out", "wt", stdout);
	#endif
	int T;
	cin >> T;
	for (int i = 0; i < T; i++)
	{
		load();
		solve();
	}
	return 0;
}
	